package stark.app.function.dream;

import com.blankj.utilcode.util.GsonUtils;
import com.stark.dream.lib.DreamModule;
import com.stark.dream.lib.model.DreamDataManager;
import com.stark.dream.lib.model.DreamKeyEverydayer;
import com.stark.dream.lib.model.DreamKeyRecommender;

import java.util.List;

import stark.app.R;
import stark.app.databinding.ActivityDreamDemoBinding;
import stark.common.basic.base.BaseNoModelActivity;

/**
 * Author：daizhongbin on 2021/12/3
 * Email：1027154338@qq.com
 * Desc:
 */
public class DreamDemoActivity extends BaseNoModelActivity<ActivityDreamDemoBinding> {
    DreamKeyRecommender mRecommender;
    DreamKeyRecommender mAllRecommender;

    @Override
    protected int onCreate() {
        return R.layout.activity_dream_demo;
    }

    @Override
    protected void initView() {
        DreamModule.init(null);
        mDataBinding.btnCategory.setOnClickListener(v -> {
            List<String> nameList = DreamDataManager.getInstance().getCategoryNames();
            mDataBinding.tvRet.setText(GsonUtils.toJson(nameList));
        });
        mDataBinding.btnRecommender.setOnClickListener(v -> {
            if (mRecommender == null) {
                mRecommender = DreamDataManager.getInstance().getDreamKeyRecommender("动物类");
            }
            List<String> keyList = mRecommender.update(10);
            mDataBinding.tvRet.setText(GsonUtils.toJson(keyList));
        });
        mDataBinding.btnAllRecommender.setOnClickListener(v -> {
            if (mAllRecommender == null) {
                mAllRecommender = DreamDataManager.getInstance().getCommonDreamKeyRecommender();
            }
            List<String> keyList = mAllRecommender.update(10);
            mDataBinding.tvRet.setText(GsonUtils.toJson(keyList));
        });
        mDataBinding.btnTodayDreamKey.setOnClickListener(v -> {
            DreamKeyEverydayer everydayer = DreamDataManager.getInstance().getDreamKeyEverydayer();
            String dreamKey = everydayer.getTodayDreamKey(false);
            mDataBinding.tvRet.setText(dreamKey);
        });
        mDataBinding.btnSpecDreamKey.setOnClickListener(v -> {
            List<String> keyList = DreamDataManager.getInstance().getSpecDreamKeyList();
            mDataBinding.tvRet.setText(GsonUtils.toJson(keyList));
        });
    }

    @Override
    protected void initData() {
    }
}
